//
//  ViewController.swift
//  AKTest
//
//  Created by Xjj2018 on 2021/8/23.
//

import UIKit


class ViewController1: UIViewController {
    
    @IBOutlet var userIn: UITextField!
    lazy var bag = DisposeBag.init()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        //监听数列输出偶数
        userIn.rx.text.map{ (input: String?) -> Int in
            if let str = input, str.count > 0 {
                if let lastNumber = str.last {
                    return Int.init(String.init(lastNumber)) ?? 1
                }
            }
            return -1
        }.filter({ x in
            return x % 2 == 0
        }).subscribe { e in
            switch e {
            case .next:
                print(e.element!)
            default:
                print("---11")
            }
            
        }.disposed(by: bag)
    }
    
}

